/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bunga;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author user
 */
public class DataPesanan {
    private String idPesanan;
    private String namaPenerima;
    private String namaPemesan;
    private String alamatPenerima;
    private String alamatPemesan;
    private String teleponPenerima;
    private String teleponPemesan;
    private String email;
    private String tglKirim;
    private String jamKirim;
    private String ucapan;
    private String jumlah;

    /**
     * @return the namaPenerima
     */
    public String getNamaPenerima() {
        return namaPenerima;
    }

    /**
     * @param namaPenerima the namaPenerima to set
     */
    public void setNamaPenerima(String namaPenerima) {
        this.namaPenerima = namaPenerima;
    }

    /**
     * @return the namaPemesan
     */
    public String getNamaPemesan() {
        return namaPemesan;
    }

    /**
     * @param namaPemesan the namaPemesan to set
     */
    public void setNamaPemesan(String namaPemesan) {
        this.namaPemesan = namaPemesan;
    }

    /**
     * @return the alamatPenerima
     */
    public String getAlamatPenerima() {
        return alamatPenerima;
    }

    /**
     * @param alamatPenerima the alamatPenerima to set
     */
    public void setAlamatPenerima(String alamatPenerima) {
        this.alamatPenerima = alamatPenerima;
    }

    /**
     * @return the alamatPemesan
     */
    public String getAlamatPemesan() {
        return alamatPemesan;
    }

    /**
     * @param alamatPemesan the alamatPemesan to set
     */
    public void setAlamatPemesan(String alamatPemesan) {
        this.alamatPemesan = alamatPemesan;
    }

    /**
     * @return the teleponPenerima
     */
    public String getTeleponPenerima() {
        return teleponPenerima;
    }

    /**
     * @param teleponPenerima the teleponPenerima to set
     */
    public void setTeleponPenerima(String teleponPenerima) {
        this.teleponPenerima = teleponPenerima;
    }

    /**
     * @return the teleponPemesan
     */
    public String getTeleponPemesan() {
        return teleponPemesan;
    }

    /**
     * @param teleponPemesan the teleponPemesan to set
     */
    public void setTeleponPemesan(String teleponPemesan) {
        this.teleponPemesan = teleponPemesan;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * @return the tglKirim
     */
    public String getTglKirim() {
        return tglKirim;
    }

    /**
     * @param tglKirim the tglKirim to set
     */
    public void setTglKirim(String tglKirim) {
        this.tglKirim = tglKirim;
    }

    /**
     * @return the jamKirim
     */
    public String getJamKirim() {
        return jamKirim;
    }

    /**
     * @param jamKirim the jamKirim to set
     */
    public void setJamKirim(String jamKirim) {
        this.jamKirim = jamKirim;
    }

    /**
     * @return the ucapan
     */
    public String getUcapan() {
        return ucapan;
    }

    /**
     * @param ucapan the ucapan to set
     */
    public void setUcapan(String ucapan) {
        this.ucapan = ucapan;
    }

    /**
     * @return the jumlah
     */
    public String getJumlah() {
        return jumlah;
    }

    /**
     * @param jumlah the jumlah to set
     */
    public void setJumlah(String jumlah) {
        this.jumlah = jumlah;
    }

    public final String getKode_Pesanan() {
        try {
//            String sql = "select ID_PAKET from IDPAKET desc";
            String sql = "select KODEPESANAN from KODEPESANAN";
            Connection con = new KoneksiDatabase().getDBConnection();
            java.sql.Statement sta = con.createStatement();
            ResultSet rs = sta.executeQuery(sql);

            rs.next();


            String result = rs.getString(1);
            int no = Integer.parseInt(result);
            no++;
            sql = "" + no;
            while (sql.length() <= 3) {
                sql = "0" + sql;
            }

            sql = "update KODEPESANAN set KODEPESANAN = '" + sql + "'";
            sta = con.createStatement();
            sta.executeUpdate(sql);
            con.close();

            return result;


        } catch (SQLException ex) {
            return "";
        }
    }

    /**
     * @return the idPesanan
     */
    public String getIdPesanan() {
        return idPesanan;
    }

    /**
     * @param idPesanan the idPesanan to set
     */
    public void setIdPesanan(String idPesanan) {
        this.idPesanan = idPesanan;
    }
    }



